package cn.kgc.crowdfundingadmin.controller;

import cn.kgc.crowdfundingadmin.common.ResultEntity;
import cn.kgc.crowdfundingadmin.pojo.Message;
import cn.kgc.crowdfundingadmin.pojo.MessageExample;
import cn.kgc.crowdfundingadmin.pojo.Role;
import cn.kgc.crowdfundingadmin.service.MessageService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 陈啸
 * @create 2020-02-19 16:05
 */
@Controller
public class MessageController {

    @Resource
    MessageService messageService;

    @ResponseBody
    @RequestMapping("/message/search/by/keyword")
    public ResultEntity<List<Message>> search(MessageExample example) {

        // 1.查询得到PageInfo对象
        List<Message> list = messageService.selectByExample(example);

        // 2.封装结果对象返回
        return ResultEntity.successWithoutData(list);
    }

    @ResponseBody
    @RequestMapping("/message/update/message")
    public ResultEntity<String> updateRole(Message message) {

        messageService.updateMessage(message);

        return ResultEntity.successWithoutData();
    }
}
